import { asyncRoutes, constantRoutes } from '@/router/index'

const state = {
  routers: []
}
const mutations = {
  setRouters(state, data) {
    state.routers = [...constantRoutes, ...data]
  }
}
const actions = {
  filterRouters(store, menus) {
    const res = asyncRoutes.filter(item => menus.includes(item.name))
    store.commit('setRouters', res)
    return res
  }
}
export default {
  namespaced: true,
  state,
  mutations,
  actions
}
